"use strict";
cc._RF.push(module, 'e92f4H/5+VMCZnr3htu+flw', 'GbzPoolManager');
// scripts/manager/GbzPoolManager.ts

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GbzPoolManager = /** @class */ (function () {
    function GbzPoolManager() {
        this._pool = {};
        this._prefab = {};
    }
    GbzPoolManager.getIns = function () {
        if (this._ins === null) {
            this._ins = new GbzPoolManager();
        }
        return this._ins;
    };
    Object.defineProperty(GbzPoolManager, "ins", {
        get: function () {
            return this.getIns();
        },
        enumerable: false,
        configurable: true
    });
    GbzPoolManager.prototype.setPrefab = function (name, prefab) {
        this._prefab[name] = prefab;
    };
    GbzPoolManager.prototype.getNode = function (prefab, parent, pos) {
        var tempPre;
        var name;
        if (typeof prefab === 'string') {
            tempPre = this._prefab[prefab];
            name = prefab;
            if (!tempPre) {
                console.log("Pool invalid prefab name = ", name);
                return null;
            }
        }
        else {
            tempPre = prefab;
            name = prefab.data.name;
        }
        var node = null;
        if (this._pool.hasOwnProperty(name)) {
            var pool = this._pool[name];
            if (pool.size() > 0) {
                node = pool.get();
            }
            else {
                node = cc.instantiate(tempPre);
            }
        }
        else {
            var pool = new cc.NodePool();
            this._pool[name] = pool;
            node = cc.instantiate(tempPre);
        }
        if (parent) {
            node.parent = parent;
            node.active = true;
            if (pos)
                node.position = pos;
        }
        return node;
    };
    // 节点放进池子
    GbzPoolManager.prototype.putNode = function (node, isActive) {
        if (isActive === void 0) { isActive = false; }
        if (!node) {
            return;
        }
        //console.log("回收信息",node.name,node)
        var name = node.name;
        var pool = null;
        // node.active = isActive
        if (this._pool.hasOwnProperty(name)) {
            //已有对应的对象池
            pool = this._pool[name];
        }
        else {
            //没有对应对象池，创建他！
            pool = new cc.NodePool();
            this._pool[name] = pool;
        }
        pool.put(node);
    };
    GbzPoolManager._ins = null;
    return GbzPoolManager;
}());
exports.default = GbzPoolManager;

cc._RF.pop();